#include<iostream>
#include<cmath>
using namespace std;

int ans = 0, cc = 0, n, k, a[20];
bool v[20] = {false};

bool isSu(int num) {
    for (int i=2; i<=sqrt(num); i++) {
        if (num % i == 0)
            return false;
    }
    return true;
}

void dfs(int count, int index) {
    if (count >= k) {
        if(isSu(ans))
            cc++;
        return;
    }
    for (int i=index; i<n; i++) {
        ans += a[i];
        v[i] = true;
        dfs(count+1, i+1);
        v[i] = false;
        ans -= a[i];
    }
}

int main() {
    cin >> n >> k;
    for (int i=0; i<n; i++)
        cin >> a[i];
    dfs(0, 0);
    cout << cc;
    return 0;
}
